package edu.thu.studio.ormdesigner.model.orm.table;

import java.util.List;

import edu.thu.studio.ormdesigner.model.ObjectSet;

public class ReferenceSet extends ObjectSet<Reference> {
    
    private static final long serialVersionUID = -6395092030037391244L;
    
    public boolean isFk(String fromId){
    	List<Reference> referenceList = this.getObjectList();
    	for(Reference _reference : referenceList){
    		List<RefColumn> refColumnList = _reference.getRefColumns().getObjectList();
    		for(RefColumn refColumn : refColumnList){
    			if(refColumn.getFrom().equals(fromId)){
    				return true;
    			}
    		}
    	}
    	return false;
    }
	
	public Reference getReferenceById(String referenceId){
		for(Reference ref : this.getObjectList()){
			if(ref.getId().equals(referenceId)){
				return ref;
			}
		}
		return null;
	}
    
}